home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
New Star Software Collection
/
NSS_Collection.iso
/
3-170 dbase 10 for windows
/
1.ima
/
SAMPLES.PAK
/
SHOWPROP.PRG
< prev
next >
Wrap
Text File
|
1993-07-26
|
5KB
|
161 lines
*******************************************************************************
* PROGRAM: Showprop.prg
*
* WRITTEN BY: Borland Late Night Crew
*
* DATE: 4/8/93
*
* UPDATED:
*
* VERSION: Alpha α
*
* DESCRIPTION: Showprop demonstrates Bladerunner's object model. It shows
* how you can create your own objects, and also displays some
* of Bladerunner's stock objects. Using these stock objects
* you can, for example, change the dimensions and captions of
* all Bladerunner windows. This program shows how you could
* change your frame window and the Command window. It also
* demonstrates how you can view the properties of an object
* using the ENUM() function.
*
* Showprop also shows how the object model lets you create
* sparse arrays. Because all objects support the index
* operator ([]), you can just assign a value to the [n]th
* property of an object. This will result in a sparse array
* of at least n elements.
*
* PARAMETERS: None
*
* CALLS: None
*
* USAGE: DO Showprop
*
*
*
*******************************************************************************
* _app is a stock object: the application
* Save old captions
private old_app_caption,old_command_caption
old_app_caption = _app.caption
old_command_caption = _app.commandwin.caption
? "=== Enumeration of the application object: "
enumprop( _app )
wait
? "=== Enumeration of one of the application's contained objects, commandwin:"
? enumprop( _app.commandwin )
wait
* settable commandwin properties in build 11 are:
* caption
* left
* top
* height
* width
*
* e.g. :
? "=== Property programming "
_app.commandwin.left = 10 && pixels are default unit for frame window
_app.commandwin.width = 500
_app.commandwin.caption = "Gimme more properties!"
_app.framewin.left = 10
_app.framewin.width = _app.framewin.width - 100
_app.caption = "Properties to the max!"
* enum works for user defined objects, as well:
a = new object() && temporary syntax; objbag() internally is a stock empty
&& object, a base for all bladerunner custom objects.
&& The actual syntax will be object().
&& 'a = object()' is equivalent to 'a = new object()',
&& which will be final syntax for dynamically creating.
&& an empty object without first defining a class.
&&
&& Syntax for instantiating a custom class (defined using
&& "class <class> [of <base class>] ) is not yet
&& implemented but will be "a = new myclass()"
? "=== Enumeration of empty user defined object: "
? enumprop( a ) && object() is empty object, so this shows nothing
wait
? "=== Enumeration after dynamically adding properties"
a.myprop = 10
a.myprop2 = 11
a.myprop3 = 12
? enumprop( a )
wait
* Each object can be treated as array because all objects support the index
* operator '[]'. The default behavior for an index is to create a sparse array
* elements (where memory for cells is dynamically allocated only as necessary).
? "=== Objects as arrays: "
a[ 5 ] = 11
? enumprop( a )
wait
* Fixed arrays are also objects. Arrays not only have index values, but also
* have dynamic properties.
? "=== Arrays as objects: "
declare x[ 5,5,5 ]
x.myprop = 10
? enumprop( x )
wait
* The memory management to implement this has other interesting implications
* for arrays, e.g. typed arrays which require minimal memory, when types
* are only int or logical. The type information is not stored, saving space.
* Reference model: You can store a reference to an object by simple assignment.
* For example, to get a reference to the frame window, one would execute:
? "=== References: "
z = _app.framewin
* now z and _app.framewin reference the same window
z.caption = "References to the max."
wait
* Restore old captions
_app.caption = old_app_caption
_app.commandwin.caption = old_command_caption
*******************************************************************************
function enumprop
* List all the properties of the parameter object by using Bladerunner's ENUM()
* function. ENUM() creates a linked list of the parameter object's
* properties. Each element of the list contains 3 properties:
* Name -- the current property's name,
* Value -- the current property's value,
* Skip() -- a reference to the next property.
* Eot -- end of table
*******************************************************************************
parameters o && passed an object to enumerate
e = new enum(o)
do while .not. e.eot
? e.name + space( max(15 - len(e.name),0)) + "--->",e.value
x = e.skip(1)
enddo
?
return .f.
************************* End of Showprop.prg *******************************